import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { View, Image } from "@tarojs/components-rn";
import { getRuntime, servicePhoneNumber, getAvatar } from "../../utils/common";
import { inject, observer } from "@tarojs/mobx-rn";
import indexStyleSheet from "./index_styles";
import right from "../../assets/img/right.png";
import bg_14 from "../../assets/img/bg_14.png";
import icon_75 from "../../assets/img/icon_75.png";
import icon_76 from "../../assets/img/icon_76.png";
import icon_77 from "../../assets/img/icon_77.png";
import icon_78 from "../../assets/img/icon_78.png";
import Tabbar from "../../components/Tabbar";
var _styleSheet = indexStyleSheet;
let Index = class Index extends Component {
  constructor(props) {
    super(props);
    this.state = {
      userInfo: {}
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '我的' });
    let userInfo = getRuntime().getUserInfo();
    if (!userInfo) {
      getRuntime().navigateTo('/pages/login/login');
      return;
    }
    this.getUserInfoFromHost();
  }
  componentDidShow() {
    this.getUserInfoFromHost();
  }
  getUserInfoFromHost() {
    let { userStore } = this.props.stores;
    userStore.getUserInfo({
      callback: res => {
        // getRuntime().setStorage('user', res) // 此处返回的信息未带token
        this.setState({
          userInfo: res
        });
      }
    });
  }
  handelRouter(url = '/pages/index/index') {
    getRuntime().navigateTo(url);
  }
  makePhone() {
    getRuntime().makePhoneCall(servicePhoneNumber);
  }
  render() {
    let { userInfo } = this.state;
    let memberType;
    (function (memberType) {
      memberType[memberType["普通用户"] = 0] = "普通用户";
      memberType[memberType["VIP会员"] = 1] = "VIP会员";
      memberType[memberType["代理商"] = 2] = "代理商";
      memberType[memberType["合伙人"] = 3] = "合伙人";
    })(memberType || (memberType = {}));
    return <View style={_styleSheet["my-my"]}>
        <Image src={bg_14} style={_styleSheet["my-bg"]} />

        <View style={_styleSheet["list-21"]}>
          <View style={_styleSheet["list-21-item"]}>
            <Image src={getAvatar(userInfo.avatar)} onClick={this.handelRouter.bind(this, '/pages/user/user_info_edit')} style={_styleSheet["img"]} />
            <View onClick={this.handelRouter.bind(this, '/pages/user/user_info_edit')} style={_styleSheet["info"]}>
              <View style={_styleSheet["list-title"]}>{userInfo.name}</View>
              <View style={_styleSheet["list-info"]}>查看和编辑个人资料</View>
              <View style={[_styleSheet["list-info"], { color: '#fece8e' }]}>{memberType[userInfo.agencyLevel]}</View>
            </View>
            <View onClick={this.handelRouter.bind(this, '/pages/user/sign')} style={_styleSheet["r"]}>
              早起打卡
            </View>
          </View>
        </View>

        <View style={[_styleSheet["wrap-box"], _styleSheet["team-integral-wrap"]]}>
          <View style={_styleSheet["team-integral"]}>
            <View onClick={this.handelRouter.bind(this, '/pages/user/my_profit')} style={_styleSheet["item"]}>
              <View style={_styleSheet["list-desc"]}>
                <View>我的收益</View>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
              <View style={_styleSheet["money"]}>￥{userInfo.commision}</View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/user/team')} style={_styleSheet["item"]}>
              <View style={_styleSheet["list-desc"]}>
                <View>我的团队</View>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
              <View style={_styleSheet["money"]}>{userInfo.teamCount}</View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/user/integral?totalPoints=' + userInfo.points)} style={_styleSheet["item"]}>
              <View style={_styleSheet["list-desc"]}>
                <View>我的积分</View>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
              <View style={_styleSheet["money"]}>{userInfo.points}</View>
            </View>
          </View>
        </View>

        <View style={[_styleSheet["wrap-box"], _styleSheet["my-from"]]}>
          <View style={_styleSheet["item-group"]}>
            <View onClick={this.handelRouter.bind(this, '/pages/user/issue')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>我的发布</View>
              <View style={_styleSheet["list-desc"]}>{userInfo.myReleaseCount}
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/user/apply_log')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>我的申请</View>
              <View style={_styleSheet["list-desc"]}>{userInfo.myApplyCount}
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>
          </View>
        </View>

        <View style={_styleSheet["wrap-box"]}>
          <View style={[_styleSheet["item-group"], _styleSheet["nav-wrap"]]}>
            <View onClick={this.handelRouter.bind(this, '/pages/user/upgrade')} style={_styleSheet["nav"]}>
              <Image src={icon_75} style={[_styleSheet["img"], _styleSheet["img1"]]} />
              <View style={_styleSheet["list-title"]}>会员升级</View>
            </View>
            <View onClick={this.handelRouter.bind(this, '/pages/user/qrcode')} style={_styleSheet["nav"]}>
              <Image src={icon_76} style={[_styleSheet["img"], _styleSheet["img2"]]} />
              <View style={_styleSheet["list-title"]}>我要赚钱</View>
            </View>
            <View onClick={this.handelRouter.bind(this, '/pages/user/bank_card')} style={_styleSheet["nav"]}>
              <Image src={icon_77} style={[_styleSheet["img"], _styleSheet["img3"]]} />
              <View style={_styleSheet["list-title"]}>银行卡</View>
            </View>
            <View onClick={this.handelRouter.bind(this, '/pages/user/address')} style={_styleSheet["nav"]}>
              <Image src={icon_78} style={[_styleSheet["img"], _styleSheet["img4"]]} />
              <View style={_styleSheet["list-title"]}>收货地址</View>
            </View>
          </View>



        </View>
        <View style={[_styleSheet["wrap-box"], _styleSheet["my-from"]]}>

          <View style={_styleSheet["item-group"]}>
            <View onClick={this.handelRouter.bind(this, '/pages/user/course')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>我的课程</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/user/order')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>商城订单</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/finance/financeQuery')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>保函查询</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/user/collection')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>我的收藏</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/public_welfare/welfare_record')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>我的公益</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/user/company_auth')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>企业认证</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>
          </View>

        </View>

        <View style={_styleSheet["my-from"]}>

          <View style={[_styleSheet["item-group"], _styleSheet["my-from"]]}>
            <View style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>客服热线</View>
              <View onClick={this.makePhone.bind(this)} style={_styleSheet["list-desc"]}>
                {servicePhoneNumber}
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/user/help')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>帮助中心</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/other/regist_agreement')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>服务协议</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>

            <View onClick={this.handelRouter.bind(this, '/pages/user/setting')} style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>设置</View>
              <View style={_styleSheet["list-desc"]}>
                <Image src={right} style={[_styleSheet["img"], _styleSheet["icon-drop-down"]]} />
              </View>
            </View>
          </View>
        </View>

        <View style={_styleSheet["from-footer"]}>技术支持：西部硅谷</View>

        <View style={{ height: '15px' }} />

        <Tabbar currentTab="user" />
      </View>;
  }
};
Index = tslib_1.__decorate([inject("stores"), observer], Index);
export default Index;